//
//  MainNavViewController.swift
//  DSBDJ4
//
//  Created by eport_user1 on 2017/11/27.
//  Copyright © 2017年 eport_user1. All rights reserved.
//

import UIKit

class MainNavViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        //设置导航栏颜色
        //self.navigationBar.barTintColor = UIColor.init(red: 13/255.0, green: 102/255.0, blue: 251/255.0, alpha: 1)
        //设置导航栏字体颜色
        self.navigationBar.tintColor = UIColor.black
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        if self.childViewControllers.count > 0 {
            
//            let button = UIButton(type: .custom)
//            button.setTitle("返回", for: .normal)
//            //button.setImage(UIImage(named: "navigationButtonReturn"), for: .normal)
//            //button.setImage(UIImage(named: "navigationButtonReturnClick"), for: .highlighted)
//            button.addTarget(self, action: #selector(back), for: .touchUpInside)
//            button.setTitleColor(.darkGray, for: .normal)
//            button.setTitleColor(.red, for: .highlighted)
//            button.sizeToFit()
//            button.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0)
//            button.contentHorizontalAlignment = .left
//            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: button)
            viewController.hidesBottomBarWhenPushed = true
            
        }
        
        super.pushViewController(viewController, animated: true)
        
        
    }
    

}


extension MainNavViewController {
    
    @objc  func back() -> Void {
        self.popViewController(animated: true)
    }
    
}



